package com.ziyun.erp.modules.supp.task;

import com.ziyun.erp.common.utils.HttpClientUtil;
import com.ziyun.erp.common.utils.JsonUtils;
import io.renren.common.utils.R;
import net.sf.json.JSONObject;

import java.util.concurrent.Callable;

/**
 * 初始化商品任务
 * @author gaosheng
 * @date 2018-12-30 9:49
 */
public class CopyGoodsTask implements Callable<R>{

    private Long sellerId;
    private Long fromSellerId;
    private String url;

    public CopyGoodsTask(Long sellerId, Long fromSellerId, String url){
        this.sellerId = sellerId;
        this.fromSellerId = fromSellerId;
        this.url = url;
    }

    @Override
    public R call() throws Exception {
        JSONObject param = new JSONObject();
        param.put("sellerId", sellerId);
        param.put("fromSellerId", fromSellerId);
        String result = HttpClientUtil.doPostJson(url, param.toString());
        R r = JsonUtils.getJsonToObject(result, R.class);
        r.put("sellerId", sellerId.toString());
        return r;
    }
}
